home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / MDATES.ZIP / MDATES.DOC < prev    next >
Encoding:
Text File  |  1994-03-08  |  5.8 KB  |  193 lines

  1.  
  2. I wrote the MDATES Class because I couldn't find a good set of Date functions
  3. anywhere!!  Not that this one is the best in the world, but it gets the job
  4. done pretty well for me!  I hope it's useful to you, and if not... Hey, it's
  5. free isn't it!
  6.  
  7. Below is an outline of the avail. functions and a breif description....
  8.  
  9. Matthew Rhoades........................................................
  10.  
  11.  
  12.  
  13.  
  14. //***************************************************************************
  15. void SystemDate(char *date);                    // returns CCYYMMDD Format
  16.  
  17.     Function to return the system date in char * CCYYMMDD Format
  18.     Ex:   MDates  date;
  19.           date.SystemDate(Buffer);
  20.           Buffer = 19940308             <today for me>
  21.  
  22.  
  23.  
  24. //***************************************************************************
  25. void PrintDate(char *date);                     // returns MMM DD, YYYY
  26.  
  27.     Function to return the system date in a "Pretty" Format for output.
  28.     Ex:   MDates  date;
  29.           date.PrintDate(Buffer);
  30.           Buffer = Mar 08, 1994          <today for me>
  31.  
  32.  
  33.  
  34. //***************************************************************************
  35. long SubMonths(long date, int x);               // returns CCYYMMDD Long
  36.  
  37.     Function to subtract x number of months from a date.
  38.     Ex:   long result;
  39.           MDates  date;
  40.           result = date.SubMonths(19940308, 4);
  41.           result = 19941108
  42.  
  43.  
  44.  
  45. //***************************************************************************
  46. long SubDays(long date, int x);                 // returns CCYYMMDD Long
  47.  
  48.     Function to subtract x number of days from a date.
  49.     Ex:   long result;
  50.           MDates  date;
  51.           result = date.SubDays(19940308, 4);
  52.           result = 19940304
  53.  
  54.  
  55.  
  56. //***************************************************************************
  57. long Date2Long(char *date);                     // CCYYMMDD Format
  58.  
  59.     Function to Convert a char *date into a long
  60.     Ex:   long result;
  61.           MDates  date;
  62.           result = date.Date2Long("19940308");
  63.           result = 19940308L
  64.  
  65.  
  66.  
  67. //***************************************************************************
  68. int  Date2String(long date, char *newdate);     // pass CCYYMMDD Format
  69.  
  70.     Function to Convert a char *date into a long
  71.     Ex:   int result;
  72.       char Date[9];
  73.           MDates  date;
  74.       result = date.Date2String(19940308, Date);
  75.       result = 1   // 1 for OK  and -1 for Invalid Date
  76.       Date = "19940308"
  77.  
  78.  
  79.  
  80. //***************************************************************************
  81. int  DaysBetween(char *dateone, char *datetwo); // CCYYMMDD Format
  82.  
  83.     Function to Compute days between two dates
  84.     Ex:   int result;
  85.           MDates  date;
  86.       result = date.DaysBetween("19940308", "19940304");
  87.           result = 4
  88.  
  89.  
  90.  
  91.  
  92. //***************************************************************************
  93. void DateFormat(char *dt, char *result, int format);
  94.  
  95.     Function to Format a given date to the specified format
  96.     Support formats are:
  97.                            STANDARD   :  MM/DD/YY
  98.                            MMDDYY     :  same
  99.                            YYMMDD     :  same
  100.  
  101.      Ex:   MDates date;
  102.            date.DateFormat( "19940308", result, STANDARD);
  103.            result  = 03/08/94
  104.  
  105.  
  106.  
  107.  
  108. //***************************************************************************
  109. void InitDate(char *dt, char *result, int format);
  110.  
  111.     Function to Init a given date from the specified format
  112.     (Opposite of DateFormat)
  113.     Support formats are:
  114.                            STANDARD   :  MM/DD/YY
  115.                            MMDDYY     :  same
  116.                            YYMMDD     :  same
  117.  
  118.      Ex:   MDates date;
  119.            date.DateFormat( "03/08/94", result, STANDARD);
  120.            result  = "19940308"
  121.  
  122.  
  123.  
  124.  
  125. //***************************************************************************
  126. int  IsValidDate( char *s );                    // pass CCYYMMDD Format
  127.  
  128.     Function to test for date validity including leap years
  129.     Ex:   int result;
  130.           MDates date;
  131.           result = date.IsValidDate( "19940308");
  132.           result  = 1 for OK, -1 for Invalid Date
  133.  
  134.  
  135.  
  136.  
  137. //***************************************************************************
  138. long Date2Julian(char *date);                   // CCYYMMDD Format
  139.  
  140.     Function to Convert a char *date into long Julian Format
  141.     Ex:   long result;
  142.           MDates date;
  143.           result = date.Date2Julian( "19940308");
  144.           result = 1755457L
  145.  
  146.  
  147.  
  148. //***************************************************************************
  149. long Julian2Long(long Julian);                  // CCYYMMDD Format returned
  150.  
  151.     Function to Convert a long Julian into long Date Format
  152.     Ex:   long result;
  153.           MDates date;
  154.           result = date.Julian2Long(1755457);
  155.           result = 19940308L
  156.  
  157.  
  158.  
  159.  
  160. //***************************************************************************
  161. void Julian2String(long Julian, char *string);  // returns CCYYMMDD Format
  162.  
  163.     Function to Convert a long Julian into char *Date Format
  164.     Ex:   char result[9];
  165.           MDates date;
  166.           date.Julian2Long(1755457, result);
  167.           result = "19940308"
  168.  
  169.  
  170.  
  171. //***************************************************************************
  172. long DMYtoJulian(int Day, int Month, int Year); // Low Level Julian Converter
  173.  
  174.     Low Level Date to Julian Convertion Function...
  175.     Ex:   long result;
  176.           MDates date;
  177.           result = date.DMYtoJulian(8, 3, 94);
  178.           result = 1755457L
  179.  
  180.  
  181.  
  182. //***************************************************************************
  183. int  Valid_Date( char *s );                     // MMDDYY Format (Low Level)
  184.  
  185.     Low Level Date Validation Function
  186.     Ex:   int result;
  187.           MDates date;
  188.           result = date.Valid_Date("030894");
  189.           result = 1 for OK, -1 for Invalid Date
  190.  
  191.  
  192.  
  193.